﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<div class="modal-dialog x-modal-dialog" style="width: 800px;margin-top: 150px;">

  <div class="modal-content">

    <div class="modal-header x-breadcrumb clearfix">

      <h2><i class="glyphicon glyphicon-fire" title=""></i>&nbsp;&nbsp;<span>编辑课程</span></h2>

      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>

    <form class="form-horizontal" method="POST" action="${ctx.host}/courses/${course.id}" data-validate="true">

      <input type="hidden" name="_method" value="PATCH" >
      <input type="hidden" name="courseId" value="${course.id}" >

      <div class="modal-body">
      
        <div class="form-group x-form-group">
          <label class="col-xs-2 control-label">课程名称：</label>
          <div class="pull-left col-xs-4">
            <input name="name" type="text" class="form-control" value="${course.name}" data-validate="required">
          </div>
          <label class="col-xs-2 control-label">上课人数：</label>
          <div class="pull-left col-xs-4">
            <input name="numbers" type="text" class="form-control" value="${course.numbers}" data-validate="required|number">
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-2 control-label">课程课时：</label>
          <div class="pull-left col-xs-4">
            <input name="hours" type="text" class="form-control" value="${course.hours}" data-validate="required|number">
          </div>
          <label class="col-xs-2 control-label">课程周数：</label>
          <div class="pull-left col-xs-4">
            <input name="weeks" type="text" class="form-control" value="${course.weeks}" data-validate="required|number">
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-2 control-label">课程有效期：</label>
          <div class="pull-left col-xs-4">
            <input name="expires" type="text" class="form-control" value="${course.expires}" data-validate="required|number">
          </div>
          <label class="col-xs-2 control-label">可冻结次数：</label>
          <div class="pull-left col-xs-4">
            <input name="freezingNumber" type="text" class="form-control" value="${course.freezingNumber}" data-validate="required|number">
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-2 control-label">线上课程：</label>
          <div class="pull-left col-xs-4">
            <input class="checkbox-switch" ${course.online ? 'checked':''} type="checkbox" data-on-color="success" data-off-color="warning" data-on-text="是" data-off-text="否" />
            <input class="checkbox-input" name="online" type="hidden" class="form-control" value="${course.online}" />
          </div>
          <label class="col-xs-2 control-label">体验课：</label>
          <div class="pull-left col-xs-4">
            <input class="checkbox-switch"  ${course.experience ? 'checked':''} type="checkbox" data-on-color="success" data-off-color="warning" data-on-text="是" data-off-text="否" />
            <input class="checkbox-input" name="experience" type="hidden" class="form-control" value="${course.experience}" />
          </div>
        </div>
        <div class="form-group x-form-group">
          <label class="col-xs-2 control-label">线下团课：</label>
          <div class="pull-left col-xs-4">
            <input class="checkbox-switch" ${course.group ? 'checked':''} type="checkbox" data-on-color="success" data-off-color="warning" data-on-text="是" data-off-text="否" />
            <input class="checkbox-input" name="group" type="hidden" class="form-control" value="${course.group}" />
          </div>
          <label class="col-xs-2 control-label">月卡季卡课程：</label>
          <div class="pull-left col-xs-4">
            <input class="checkbox-switch" ${course.year ? 'checked':''} type="checkbox" data-on-color="success" data-off-color="warning" data-on-text="是" data-off-text="否" />
            <input class="checkbox-input" name="year" type="hidden" class="form-control" value="${course.year}" />
          </div>
        </div>
        
        <div class="modal-footer">
          <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
          <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
        </div>
        
      </div>
      
    </form>
  </div>
</div>

<script>
$(function(){
  $('.checkbox-switch').bootstrapSwitch({
    onSwitchChange: function(event, state) {
      console.log($(event.currentTarget));
      $(event.currentTarget).parents(".col-xs-4").children(".checkbox-input").val(state ? 'true' : 'false');
    }
  });
})
</script>

